import axios from 'axios';

const instance = axios.create({
  baseURL: 'https://36.158.228.122:50280/',
  timeout: 10000,
  headers: {
    'Content-Type': 'application/json', 
    'Accept': '*/*', 
    'Host': '36.158.228.122:50280',
    'Connection': 'keep-alive'
  }
});

instance.interceptors.request.use(
  config => {
    // console.log(config);
    return config;
  },
  error => {
    console.log(error);
    return Promise.reject(error);
  }
);

instance.interceptors.response.use(
  response => {
    // console.log(response);
    return response;
  },
  error => {
    console.log(error);
    return Promise.reject(error);
  }
);

const AxiosMethods = {
  get(endpoint, params) {
    return instance.get(endpoint, params);
  },
  post(endpoint, data) {
    return instance.post(endpoint, data);
  },
  put(endpoint, data) {
    return instance.put(endpoint, data);
  },
  delete(endpoint) {
    return instance.delete(endpoint);
  }
}

export default AxiosMethods;
